import {getContract} from 'config/api'

export default {
  namespace: 'contract',
  state:{
    orderId: null,
    contractData: {}
  },
  effects:{
    *getContractEff(action,{call,put,select}){
      let orderId = yield select(state => state.contract.orderId)
     let contractData = yield call(getContract, orderId)
     console.log("​*getContractEff -> contractData", contractData)
     let {pay_time} = contractData
     let contractId = new Date(pay_time).getTime()
     console.log("​*getContractEff -> contractId", contractId)
     yield put({
       type: 'save',
       payload: {contractData:{...contractData,contractId}}
     })
    }
  },
  reducers:{
    save(state,{payload}){
      return {...state,...payload}
    }
  }
}
